fix: auto-select a company when no default is set (#4)#8
Merged
Conversation
Task: Ledger Lab page opened with no default company showed "No company found. Please set a default company." and empty boxes (GitHub issue #4). Key decisions: - Frontend now resolves a company before the first load: if Frappe's client default ("company") is unset, fall back to the first available Company (frappe.db.get_list, oldest first) so the page always opens with data instead of erroring out. - refresh() also syncs the header picker to the server-resolved company, so the field never shows blank while data is loaded (covers the global-default-only case). The change-handler guard prevents a reload loop on programmatic set_value. Files changed: - ledger_lab/ledger_lab/page/ledger_lab/ledger_lab.js (new async init_company(); constructor sequencing; refresh() picker sync) Verified (agent-browser, ledger.localhost): - Cleared global + user company defaults -> reproduced the warning/empty boxes, then confirmed fix falls back to BWH and loads data, no warning. - Restored defaults -> normal case still selects BWH, loads data. Notes for next iteration: only one company (BWH) exists on this bench, so company-switching wasn't re-exercised (logic unchanged). Issue #5 (basic transaction-list filters: show-cancelled, root-type) remains open. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…y-selection # Conflicts: # ledger_lab/ledger_lab/page/ledger_lab/ledger_lab.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Opening Ledger Lab with no default company set showed a warning —
"No company found. Please set a default company." — and empty boxes (—).
Closes #4
Fix
init_company()(new): before the first load, if Frappe's client default(
frappe.defaults.get_default("company")) is unset, fall back to the firstavailable
Company(oldest first) and select it in the header picker. The pagenow always opens with data instead of erroring out.
refresh()picker sync: reflect the server-resolved company in the headerfield so it never shows blank while data is loaded (covers the
global-default-only case). The existing change-handler guard (
val !== this.company)prevents a reload loop on programmatic
set_value.No backend changes.
Verification (agent-browser,
ledger.localhost)Defaults were temporarily cleared to reproduce, then restored.
🤖 Generated with Claude Code